//
//  YIem_SY_One_ViewController.m
//  B段_开眼
//
//  Created by YIem on 16/5/4.
//  Copyright © 2016年 Howie. All rights reserved.
//

#import "YIem_SY_One_ViewController.h"
#import "YIem_SY_One_Model.h"
#import "YIem_SY_One_ViewModel.h"


#import "YIem_SY_One_TOP_View.h"
#import "YIem_SY_One_Center_VIew.h"
#import "YIem_SY_One_Bottom_View.h"
@interface YIem_SY_One_ViewController ()

@end

@implementation YIem_SY_One_ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    
    [self dataBase];
}


- (void)dataBase
{
    NSString *url = @"http://api.map.baidu.com/telematics/v3/weather?location=%E5%A4%A7%E8%BF%9E&output=json&ak=OnMGDYzjfKFPzurnK9o4ui2a";
    [YIem_SY_One_ViewModel getDataWithPage:url andUpdate:YES andBlock:^(NSMutableDictionary *dic) {
        
        
        
        self.view.backgroundColor = [UIColor whiteColor];
        
        UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
        scroll.contentSize = CGSizeMake(0, self.view.frame.size.height * 1.4);
        scroll.bounces = NO;
        scroll.showsHorizontalScrollIndicator = NO;
        scroll.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"stock-photo-110851015.jpg"]];
        [self.view addSubview:scroll];
        //
        YIem_SY_One_TOP_View *top = [[YIem_SY_One_TOP_View alloc] initWithFrame:CGRectMake(0, 0, scroll.frame.size.width, self.view.frame.size.height / 4)];
        top.titleStr = [dic objectForKey:@"currentCity"];
        top.pmStr = [dic objectForKey:@"pm25"];
        top.arr = [dic objectForKey:@"weather"];
        [scroll addSubview:top];
        YIem_SY_One_Center_VIew *center = [[YIem_SY_One_Center_VIew alloc] initWithFrame:CGRectMake(0, top.frame.origin.y + top.frame.size.height, top.frame.size.width, top.frame.size.height * 3)];
        center.arr = [dic objectForKey:@"index"];
        [scroll addSubview:center];
        
        YIem_SY_One_Bottom_View *bottom = [[YIem_SY_One_Bottom_View alloc] initWithFrame:CGRectMake(0, center.frame.origin.y + center.frame.size.height, top.frame.size.width, top.frame.size.height)];
        
        bottom.arr = [dic objectForKey:@"weather"];
        [scroll addSubview:bottom];
        

        
    }];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
